package com.jxj.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @Author Cambria
 * @creat 2021/9/6 19:50
 */
@Configuration
public class CROSConfig {

    @Bean
    public WebMvcConfigurer crosConfig() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**")
                        .allowedOrigins("*")
                        .allowedMethods("GET" , "POST" , "PUT" , "DELETE" , "OPTIONS")
                        .allowCredentials(false).maxAge(3600);
            }
        };
    }

}
